package ru.vsu.amm.fuzzy.problems;

import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Scanner;

/**
 * 
 * @author Иванов Илья
 * @since 03 января 2013
 *
 */
public class Utils {
	
	public static List<String> readLabels(String fileName) throws IOException {
		List<String> labels = new ArrayList<>();
		for (String line : Files.readAllLines(FileSystems.getDefault().getPath(fileName), StandardCharsets.UTF_8)) {
			Scanner sc = new Scanner(line);
			sc.useLocale(Locale.US);
			StringBuffer label = new StringBuffer();
			while (sc.hasNext() && !sc.hasNextDouble()) {
				if (label.length() > 0)
					label.append(' ');
				label.append(sc.next());
			}			
			sc.close();
			if (label.length() > 0)
				labels.add(label.toString());
		}
		
		return labels;
	}
}